package 强化训练;

import java.util.Scanner;

public class 两种排序方法 {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String[] strs = new String[n];
        for(int i = 0;i < strs.length;i++){
            strs[i] = sc.next();
        }
        boolean isLength = true;
        boolean isDic = true;
        for(int i = 0;i < strs.length - 1; i ++){
            if(strs[i+1].compareTo(strs[i]) < 0){//后一个比前面一个小，就不是字典序
                isDic = false;
            }
            if(strs[i+1].length() - strs[i].length() < 0){//后面长度比前面长度小
                isLength = false;
            }
        }
        if(isDic && isLength){
            System.out.println("both");
        }else if(isDic){
            System.out.println("lexicographically");
        }else if(isLength){
            System.out.println("lengths");
        }else{
            System.out.println("none");
        }
    }
}
